#include<iostream>
#include<vector>
#include<string>
using namespace std;
int bin(int x)
{
	int count=0;
	while(x!=0)
	{
		count+=x%2;
		x=x/2;
	}
	return count;
}
int oct(int x)
{
	int count=0;
	while(x!=0)
	{
		count+=x%8;
		x=x/8;
	}
	return count;
}
int main()
{
	int count = 0,x=0;
	while(count!=23)
	{
		x++;
		if(bin(x)==oct(x)) {
		count++;
		cout << x<<endl; 
		}
	}
	cout <<x;
}
